\documentclass[journal]{IEEEtran}
\usepackage{cite}
\usepackage{url}
\usepackage{listings}
\usepackage{subfig}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{color}

\hyphenation{op-tical net-works semi-conduc-tor}

\linespread{1.3}

\newcommand{\java}{
\lstset{language=Java,
		basicstyle=\small,
		tabsize=2}
}

\newcommand{\vb}{
\lstset{language={[Visual]Basic},
		basicstyle=\small,
		tabsize=2}
}

\begin{document}
\title{Why Visual Basic Does not Promote Deliberate Actions and Structured Code}
\author{Anthony~Naddeo,~\IEEEmembership{Student Member,~IEEE,}}%

% The paper headers
\markboth{COS301 Prelim 2, November 22 2011}%
{Shell \MakeLowercase{\textit{et al.}}: Bare Demo of IEEEtran.cls for Journals}
% The only time the second header will appear is for the odd numbered pages
% after the title page when using the twoside option.

\maketitle
\begin{abstract}
%\boldmath
This paper examines some of the behavior a student's first programming language should teach and discusses why Java is better suited to meet these criteria than Visual Basic. Be forewarned, this paper is from the point of view of an inexperienced Visual Basic programmer (arguably merely a Visual Basic spectator).
\end{abstract}

\begin{IEEEkeywords}
programming, learning, Visual Basic, Java, coding practice
\end{IEEEkeywords}





%------------------------------------------------------------
% Section I: Introduction
%------------------------------------------------------------
\section{Introduction} 

\IEEEPARstart{A}{} first programming language should be one that teaches (and enforces) productive coding habits and consistent, readable coding style. The following list will enumerate what these criteria specifically imply.

\begin{itemize} 
\item \textbf{Deliberateness.} Everything a programmer does when he is learning should be as deliberate as possible. Being able to create an untyped variable as an integer, implicitly convert it to a double and then assign a string to it does not provoke any thought whatsoever about how this data is being represented internally.
\item \textbf{Functional Programming.} It is always best to make code as modular as possible. A language that promotes separation of concerns, as opposed to monolithic, linear code would be ideal.
\item \textbf{Structure.} How code is organized is extremely important in relation to its readability and maintainability. Object Oriented languages quickly became popular because of how the languages themselves enabled modularity and organization.
\end{itemize}  

The following sections compare Visual Basic and Java against these criteria and each other in order to determine how well they would lend to a first learning experience. 





%------------------------------------------------------------
% Section II: Java vs Visual Basic
%------------------------------------------------------------
\section{Java vs Visual Basic}\label{sec:vs}

The purpose of Visual Basic was to democratize computing and ease the process of becoming a programmer by simplifying the learning experience. In its effort to simplify programming, Visual Basic changed the way that programmers interface with the language. In most settings (including here at the University of Maine), students learn Visual Basic through a specialized GUI that supports a drag-and-drop coding style.  

To many of these students, a \textit{program} is a box in the Windows operating system that allows them to interact with the computer in some specialized way. This naive impression is reinforced when they are told that they are learning how to create programs as they drag buttons and text boxes onto a screen. To further the misleading experience, the compilation process consists solely of clicking on a ``Run'' button that compiles the code (that they may or may not have look at) into an executable and runs the application. 


%------------------------------------------------------------
\subsection{General Points against Visual Basic}\label{sec:cons}

Before going into specific details, it is worth mentioning some of the unattractive characteristics Visual Basic possesses; even from a non-academic point of view.

Visual Basic can only be run on one operating system: Microsoft Windows. In a world where a dwarfing majority of personal computers are running Windows, it is important that students know that Windows is not synonymous with PC. Any language should be able to run on any operating system, let a lone a beginners first language. 

As mentioned before, the main interaction most students will have with the language is in the form of clicking and dragging various objects into a window. The only time the code needs to be seen is when buttons and check boxes need to be assigned functionality. This completely absolves students of their responsibilities in structuring their source code, allowing them to fill out skeleton programs generated by an IDE; behavior that will not promote productive, efficient coding when they are attempting to solve non-trivial problems, especially in teams.

The following section will show specifically how Visual Basic not only fails to promote good coding style, but actively promotes the opposite. 

%------------------------------------------------------------
\subsection{Enforcing Good Practice}\label{sec:delib}

Java is one of the stricter languages when it comes to enforcing typing and object oriented programming. Every file needs to be a class named after the filename, every program needs to have a single static main method, and every variable needs to be explicitly declared as a particular type; anything a programmer does needs to be deliberate. If any of the code does not meet Java's requirements then there will be a compilation error. This is very different from the approach that  Visual Basic takes. The following shows how Visual Basic's weak typing system and lose style requirements can lead to a valid executable and reinforcement of questionable programming habits.

\begin{figure}[H]
\vb
\begin{lstlisting}
Imports System

Public Module modmain
	Function myFunc(byRef arg As Integer)
		arg = 5.5
	End Function
	Sub Main()
		Dim x = 5
		myFunc(x)
		Console.WriteLine (x)
	End Sub
End Modul
\end{lstlisting}
\caption{Ambiguous Visual Basic program.}
\label{fig:vbhello}
\end{figure}

Not only can the keywords \texttt{Sub} and \texttt{Function} be seemingly interchanged with identical results, but arguments can be passed by value or by reference. In any instance this may not seem like a big deal, but when a single programs goes back and fourth between the two styles of parameter passing it makes it very hard for another person to follow the code. 

Visual Basic does not enforce type declaration either. The variable \texttt{x} is created with an implicit type of \textit{Integer} because of the value it was assigned, then passed to a function that assigns the value of a double to it, resulting in the actual value rounding to 6. 

This code has no direct counterpart in Java. In fact, the compiler would signal an error when the integer was assigned the value of a double. The following is how Java \textit{makes} you rewrite this code.

\begin{figure}[H]
\java
\begin{lstlisting}
import java.lang.System;

public class MyClass{

	public double myFunc(int arg){
		double d = arg + .5;
		return d;
	}

	public static void main(String [] arg){
		MyClass t = new MyClass();

		int i = 5;
		double d = t.myFunc(i);
		System.out.println(d);
	}
}
\end{lstlisting}
\caption{Java rewrite.}
\label{fig:javahello}
\end{figure}

The Visual Basic code could have been interpreted in two different ways. The coder could have meant to round the integer, or he could have meant to convert it to a double. The Java code assumes the intention was converting to a double, but the actual behavior had to be explicitly decided upon and coded out. The structure in the Java program is uniform as well. If a function does not return anything then it is explicitly declared as returning \texttt{void}, not left blank like in Visual Basic. 

Java also enforces its typing system. Two variables are required in Java because the data they are holding are represented in very different ways; something a programmer should be aware of. 

This simple code also shows an Object Oriented programming model being enforced. Any function that is not static is going to be callable only through the class in which it was created. This leads to a program separated into Classes composed of relevant methods to that class, all explicitly typed and declared.
 


%------------------------------------------------------------
% Section X: Conclusion
%------------------------------------------------------------
\section{Conclusion}

Possibly the worst part about Visual Basic teaching sloppy, inattentive coding habits is that the language itself is hardly useful outside of education. It confronts students, forms horrid coding instincts and leaves them to enter a world where nothing they have learned will be useful, including the only syntax they are familiar with.

Many programmers find it frustrating to program in Java because of how verbose and strict the language can be. This may be an annoyance to a seasoned software engineer when switching over to it, but they are fundamental lessons to a new programmer; lessons that Visual Basic students hopefully learn sometime after their first programming experience.


%\appendices
%\begin{thebibliography}{1}
%\bibitem{IEEEhowto:kopka}
%H.~Kopka and P.~W. Daly, \emph{A Guide to \LaTeX}, 3rd~ed.\hskip 1em plus
%  0.5em minus 0.4em\relax Harlow, England: Addison-Wesley, 1999.
%\end{thebibliography}

\end{document}


